package com.mybatis.audition;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author liuxiaoding
 * @Date 2022/3/21
 **/
public class TestItem {
    public static String data="{\"@timestamp\":\"2022-03-28T07:04:09.524Z\",\"@metadata\":{\"beat\":\"filebeat\",\"type\":\"doc\",\"version\":\"6.6.2\",\"topic\":\"gw-cdr\"},\"prospector\":{\"type\":\"log\"},\"gw-type\":\"vos\",\"beat\":{\"name\":\"vos-010-1\",\"hostname\":\"vos-server1\",\"version\":\"6.6.2\"},\"message\":\"\\\"02162488611\\\",\\\"02162488611\\\",\\\"16601193500\\\",\\\"16601193500\\\",\\\"223.71.234.78\\\",\\\"g711Alaw64K\\\",\\\"USER_北京快手科技有限公司外呼\\\",\\\"Avaya Communicator for iPhone/3.25.0 (3.25.0.73.10; Avaya CSDK; iPhone12,1) AVAYA-SM-6.3.17.0.631705 Avaya CM/R016x.03.0.141.0 AVAYA-SM-6.3.17.0.631705\\\",\\\"02162488611\\\",1,\\\"47.103.169.66\\\",\\\"g711Alaw64K\\\",\\\"3RD_ali_out_3\\\",\\\"\\\",\\\"80916601193500\\\",1,1,2,60,1648451030853,1648451048118,10750,3229,18,\\\"1\\\",60,0.0,0.0,0.0,0,0.0,0.0,\\\"2221061002\\\",\\\"北京快手科技有限公司\\\",\\\"1\\\",0.0,0.0,0.0,0,\\\"阿里大于\\\",\\\"阿里大于\\\",1942979307,\\\"MBX3000\\\",6732165035557764001,\\\"0d6774bf1a9ec1398b61ce384c00\\\",\\\"317b574863616c6c650d2968@36.110.46.253\\\",1,0,-7,0,0,-1\",\"source\":\"/data/cdrs/cdr_20220328_123510.csv\",\"offset\":86882602,\"input\":{\"type\":\"log\"},\"gw-name\":\"010\",\"host\":{\"name\":\"vos-010-1\"},\"log\":{\"file\":{\"path\":\"/data/cdrs/cdr_20220328_123510.csv\"}}}";

    public static void main(String[] args) {
        String str="abccccdd";
        System.out.println(longestPalindrome(str));
    }

    public static int longestPalindrome(String s) {
        int[] count = new int[128];
        int length = s.length();
        for (int i = 0; i < length; ++i) {
            char c = s.charAt(i);
            count[c]++;
        }

        int ans = 0;
        for (int v: count) {
            ans += v / 2 * 2;
            if (v % 2 == 1 && ans % 2 == 0) {
                ans++;
            }
        }
        return ans;
    }
}
